package com.zhou.spring.cloud.balancer.feign;

import com.zhou.spring.cloud.balancer.feign.config.ProvincialPlatformConfiguration;
import com.zhou.spring.cloud.balancer.feign.config.SignatureDto;
import com.zhou.spring.cloud.balancer.feign.mode.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@FeignClient(name = "provincialPlatformFeign", url = "http://csb/", configuration = {ProvincialPlatformConfiguration.class})
public interface ProvincialPlatformFeign {

    @PostMapping(headers = {
            "method=${testValue:123}",
            "content-type=application/x-www-form-urlencoded; charset=UTF-8",
            "Accept=application/json"
    })
    ProvinceToken getAccessToken(@RequestParam String grant_type, @RequestParam String client_id, @RequestParam String client_secret);


    /**
     * 获取签名
     */
    @PostMapping(headers = {
            "method=${province.signature:123}",
            "Accept=application/json"
    })
    Map getSignature(@RequestParam("access_token") String accessToken, @RequestBody SignatureDto signatureDto);

    @PostMapping(headers = {
            "method=${province.insurance:123}",
            "content-type=application/x-www-form-urlencoded; charset=UTF-8",
            "Accept=application/json"
    })
    SocialInsuranceRes getSocialInsurance(@RequestHeader Map<String, String> headers, @SpringQueryMap SocialInsuranceQueryDto queryDto);


    /**
     * @param headers
     * @param queryDto
     * @return
     */
    @GetMapping(headers = {
            "method=${province.education:123}",
            "Accept=text/xml"
    })
    XuexinRes getEducationInfo(@RequestHeader Map<String, String> headers, @SpringQueryMap UserQueryDto queryDto);

}
